home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-03-19 | 8.1 KB | 236 lines | [TEXT/MPS ] |
- #
- # ****************************************************************************
- #
- # File Name: IvyOperations.Lib
- #
- # Contains: Tasks which extend the basic functionality of the Ivy.vulib.
- #
- # Written by: KTA
- #
- # Copyright: © 1993-1997 by Apple Computer, Inc., all rights reserved.
- #
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- #
- # Vers Date Author Description
- # ---- -------- ------ ---------------------------------------------
- # 1.4.0 2/12/97 JAS Added 'vers' resources to library.
- # These should always match tool version when tool is revved.
- # <1.0.3> 2/16/95 KTA _Ivy() - Replaced with new version of standard template which
- # fixes some problems.
- # <1.0.2> 1/19/95 KTA Changed the name of ExceptionHandler() to ExceptionDispatcher().
- # <1.0.1> 1/13/95 KTA Changed parameter name.
- # <1> 1/12/95 KTA Created - first checked in.
- #
- # ****************************************************************************
- #
-
-
- ########################################################################
- # External libraries
- #=======================================================================
- Libraries "Ivy Tool Declaration.vulib", "Ivy.vuLib", "Output.Lib", "String.Lib", "ExceptionHandling.Lib";
-
- #########################################################################
- # _Ivy(pOnTheTarget := true)
- #========================================================================
- # Author: KTA
- # Description: Does the exception handling for the Ivy. All high level tasks
- # should call this routine for file tool services. Handles initialization
- # of tool automatically.
- # Parameters: pServiceOrTask - Name of the Service
- # pParamList - List of parameters
- # pOnTarget - Flag to indicate whether the service should be performed
- # the host or the target. 1 = target/0 = host.
- # Returns: Whatever the file tool returns
- # Examples: _Ivy('LocateImage', {'fileName'},1);
- # Assumptions: None
- #========================================================================
- # History:
- # KTA 12/12/94 Only match the mouse if pOnTarget is true
- # KTA 2/16/95 coerce pOnTarget to be either true or false, Temporarily
- # turn commandexceptions off, check scripterror, reset
- # commandexceptions, and if necessary throw scripterror
- #########################################################################
- TASK _Ivy(pServiceOrTask, pParamList := {}, pOnTarget := true, pIsRetry := 0)
- begin
- Try
- begin
- returnVal := undefined;
- ParamType := TypeOf(pServiceOrTask);
-
- if (ParamType = 'string') # Service Call
- begin
- if (pOnTarget)
- pOnTarget := true;
- else
- pOnTarget := false;
- if not(global gIvyInitFlag = pOnTarget)
- begin
- try
- begin
- temp := CommandExceptions(0);
- IvyInit := Ivy("Initialize", pOnTarget ); # initialize Ivy
- InitError := Scripterror();
- CommandExceptions(temp);
- if (IvyInit[1] <> 0) # If error
- begin
- println "Ivy error ( ", IvyInit[1], ", ", IvyInit[3] , " )";
- gIvyInitFlag := undefined;
- if (CommandExceptions())
- throw InitError;
- return(IvyInit);
- end;
- else
- gIvyInitFlag := pOnTarget;
- end;
- catch theErr
- begin
- ExceptionDispatcher(theErr);
- return(IvyInit);
- end;
- end;
-
- try
- begin
- NumParams := Card(pParamList);
- switch NumParams
- begin
- case 0: # 0 parameters
- returnVal := Ivy(pServiceOrTask);
- case 1: # 1 parameter
- returnVal := Ivy(pServiceOrTask, pParamList[1]);
- case 2: # 2 parameters
- returnVal := Ivy(pServiceOrTask, pParamList[1], pParamList[2]);
- case 3: # 3 parameters
- returnVal := Ivy(pServiceOrTask, pParamList[1], pParamList[2], pParamList[3]);
- case 4: # 4 parameters
- returnVal := Ivy(pServiceOrTask, pParamList[1], pParamList[2], pParamList[3], pParamList[4]);
- case 5: # 5 parameters
- returnVal := Ivy(pServiceOrTask, pParamList[1], pParamList[2], pParamList[3], pParamList[4], pParamList[5]);
- case 6: # 6 parameters
- returnVal := Ivy(pServiceOrTask, pParamList[1], pParamList[2], pParamList[3], pParamList[4], pParamList[5], pParamList[6]);
- default: # error
- println "Error - unsupported number of parameters - {NumParams}";
- end;
-
- if (returnVal[1] <> 0) # If error
- begin
- if(returnVal[1] = -1) and not (pIsRetry) # Not initialized, and haven't retried already
- begin
- global gIvyInitFlag := undefined;
- returnVal := _Ivy(pServiceOrTask, pParamList, pOnTarget, 1);
- end;
- end;
- else if(pServiceOrTask = 'Quit') # Reset the global gIvyInitFlag when we quit
- global gIvyInitFlag := undefined;
-
- end;
- catch theErr
- begin
- if(theErr = -1220) and not (pIsRetry)
- begin
- global gIvyInitFlag := undefined;
- returnVal := _Ivy(pServiceOrTask, pParamList, pOnTarget, 1);
- end;
- else
- exceptionDispatcher(theErr);
- end;
- end;
- else if(ParamType = 'task')
- begin
- NumParams := Card(pParamList);
- switch NumParams
- begin
- case 0: # 0 parameters
- returnVal := call (pServiceOrTask);
- case 1: # 1 parameter
- returnVal := call (pServiceOrTask, pParamList[1]);
- case 2: # 2 parameters
- returnVal := call (pServiceOrTask, pParamList[1], pParamList[2]);
- case 3: # 3 parameters
- returnVal := call (pServiceOrTask, pParamList[1], pParamList[2], pParamList[3]);
- case 4: # 4 parameters
- returnVal := call (pServiceOrTask, pParamList[1], pParamList[2], pParamList[3], pParamList[4]);
- case 5: # 5 parameters
- returnVal := call (pServiceOrTask, pParamList[1], pParamList[2], pParamList[3], pParamList[4], pParamList[5]);
- case 6: # 6 parameters
- returnVal := call (pServiceOrTask, pParamList[1], pParamList[2], pParamList[3], pParamList[4], pParamList[5], pParamList[6]);
- default: # error
- println "Error - unsupported number of parameters - {NumParams}";
- end;
- end;
-
- if(pOnTarget) # To cause target errors to throw if Xtools are called
- match[mouse];
-
- return(returnVal);
- end;
- Catch theError
- ExceptionDispatcher(theError);
- end;
-
- #########################################################################
- # InitIvy(pOnTheTarget := true)
- #========================================================================
- # Author: KTA
- # Description: Initializes the Ivy
- # Parameters: pOnTheTarget - True if you want to launch the Ivy on
- # the target machine. False if on the Host.
- # Returns: 0 - Couldn't initialize
- # 1 - Init On Target
- # 2 - Init On Host
- # Examples: InitIvy();
- # Assumptions: None
- #========================================================================
- # History:
- # KTA 12/12/94 Updated to call _Ivy()
- #########################################################################
- TASK InitIvy(pOnTheTarget := true)
- begin
- returnVal := 0;
- IvyInit := _Ivy( "Initialize", {pOnTheTarget} ); # Launch Ivy
- if IvyInit[1] <> 0 # If error during initialization,
- begin
- println "Ivy could not be initialized"; # print error
- println "Error ", IvyInit[1], ". ", IvyInit[3] ;
- end;
- else
- begin
- if (pOnTheTarget) # Was it on the Target
- returnVal := 1;
- else # Or was it on the Host
- returnVal := 2;
-
- end;
- return(returnVal);
- end;
- #########################################################################
- # QuitIvy()
- #========================================================================
- # Author: KTA
- # Description: Quits Ivy
- # Parameters: none
- # Returns: 0 - Couldn't Quit
- # 1 - Quit Successfully
- # Examples: QuitIvy();
- # Assumptions: None
- #========================================================================
- # History:
- # KTA 1/6/95 Created
- #########################################################################
- TASK QuitIvy(pOnTheTarget := true)
- begin
- IvyQuit := _Ivy( "Quit"); # Quit Ivy
- if (IvyQuit[1] <> 0) # If error during initialization,
- begin
- println "Ivy could not be quit"; # print error
- println "Error ", IvyQuit[1], ". ", IvyQuit[3] ;
- returnVal := 0; # Error
- end;
- else
- returnVal := 1; # Success
- return(returnVal);
- end;
-